// Client.java
import java.util.Arrays;
import java.util.List;

public class Client {
    public static void main(String[] args) throws InterruptedException {
        // 初始化论文清单
        final PaperList listOfRainy = new PaperList("Rainy", Arrays.asList(
            new Thesis("Science"),
            new ConferencePaper("Science"),
            new JournalPaper("Technology")
        ));
        // 初始化学生
        final List<Student> students = Arrays.asList(
            new Student("Cloudy", 1, PaperType.Thesis),
            new Student("Sunny", 1, PaperType.JournalPaper),
            new Student("Windy", 2, PaperType.Any)
        );

        // 多线程选择论文
        for (Student student : students) {
            new Thread(() -> {
                try {
                    listOfRainy.selectPaperByRandom(student);
                } catch (NoEnoughPapersException | IllegalArgumentException e) {
                    System.out.println(e.getMessage());
                }
            }).start();
        }

        Thread.sleep(1000); // 等待线程执行完成
        System.out.println("选择结果：");
        System.out.println(listOfRainy.getSelectionResult());

        // 测试访问者模式（统计选择论文的学生数）
        StudentCountVisitor visitor = new StudentCountVisitor();
        listOfRainy.getSelectionResult().accept(visitor);
        System.out.println("选择论文的学生数：" + visitor.getCount());
    }
}